home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / HDX_BACK / HDX401.ATB / PART.C < prev    next >
Encoding:
C/C++ Source or Header  |  2001-02-09  |  3.0 KB  |  179 lines

  1. /* part.c */
  2.  
  3.  
  4. /*
  5.  * 24-Nov-88    jye.     change and add codes so that can be used for MS-DOS
  6.  */
  7. #include "obdefs.h"
  8. #include "gemdefs.h"
  9. #include "osbind.h"
  10. #include "mydefs.h"
  11. #include "part.h"
  12. #include "bsl.h"
  13. #include "hdx.h"
  14. #include "addr.h"
  15.  
  16.  
  17. extern char sbuf[];
  18. extern int npart;
  19. extern int uplim;
  20. extern long bslsiz;
  21. extern long gbslsiz();
  22. extern int noinfo;        /* 1: no information inside the wincap */
  23.  
  24.  
  25. /*
  26.  * Fill in partition entry with default information
  27.  * and configuration values from the current "pr" wincap entry.
  28.  *
  29.  */
  30. fillpart(n, part)
  31. int n;
  32. PART *part;
  33. {
  34.     long num;
  35.     char *partid;
  36.     char *idstr = "XX";
  37.     char *wgetstr();
  38.  
  39.     idstr[1] = n + '0';
  40.  
  41.     /* see if `pX' is mentioned */
  42.     *idstr = 'p';
  43.     if (wgetnum(idstr, &num) == OK)
  44.     {
  45.     /* do the ST partition assignment */
  46.         npart++;
  47.         part->p_siz = (LONG)(num / 512);
  48.            part->p_flg = P_EXISTS;
  49.         if (part->p_siz < MB16)    {
  50.             part->p_id[0] = 'G';
  51.             part->p_id[1] = 'E';
  52.             part->p_id[2] = 'M';
  53.         } else {
  54.             part->p_id[0] = 'B';
  55.             part->p_id[1] = 'G';
  56.             part->p_id[2] = 'M';
  57.         }
  58.     }
  59. }
  60.  
  61.  
  62. /* set the partition informations to the partition structures */
  63.  
  64. setpart(part, hsize)
  65. PART *part;
  66. long hsize;
  67. {
  68.     long onepart, remain;
  69.     int i;
  70.  
  71.     npart = 4;
  72.     onepart = hsize/4;
  73.     remain = (hsize - onepart * 4) / 4;
  74.     for ( i = 0; i < 4; i++, part++)    {
  75.         if (i == 4)    {
  76.             part->p_siz = hsize - (onepart + remain) * 3;
  77.         } else {
  78.             part->p_siz = onepart+remain;
  79.         }
  80.            part->p_flg = P_EXISTS;
  81.         if (part->p_siz < MB16)    {
  82.                part->p_id[0] = 'G';
  83.                part->p_id[1] = 'E';
  84.                part->p_id[2] = 'M';
  85.         } else {
  86.                part->p_id[0] = 'B';
  87.                part->p_id[1] = 'G';
  88.                part->p_id[2] = 'M';
  89.         }
  90.     }
  91. }
  92.  
  93.  
  94.  
  95. /*
  96.  * Force checksum of sector image to a value
  97.  */
  98. forcesum(image, sum)
  99. UWORD *image;
  100. UWORD sum;
  101. {
  102.     register int i;
  103.     register UWORD w;
  104.  
  105.     w = 0;
  106.     /* up limit is half of buffer size - 2 */
  107.     for (i = 0; i < ((UWORD)BPS/2 - 1); ++i)
  108.     w += *image++;
  109.     *image++ = sum - w;
  110. }
  111.  
  112.  
  113. /*
  114.  * Put word in memory in 8086 byte-reversed format.
  115.  *
  116.  */
  117. iw(wp, w)
  118. UWORD *wp;
  119. UWORD w;
  120. {
  121.     char *p;
  122.  
  123.     p = (char *)wp;
  124.     p[0] = (w & 0xff);
  125.     p[1] = ((w >> 8) & 0xff);
  126. }
  127.  
  128. /*
  129.  * Put long word in memory in 8086 word-reversed format.
  130.  *
  131.  */
  132. ilong(lp, l)
  133. long *lp;
  134. long l;
  135. {
  136.     UWORD *p;
  137.  
  138.     p = (UWORD *)lp;
  139.     iw(&p[0],(UWORD)(l & 0xffff));
  140.     iw(&p[1],(UWORD)((l >> 16) & 0xffff));
  141. }
  142.  
  143. /*
  144.  * Get long word in memory, from 8086 word-reversed format.
  145.  *
  146.  */
  147. glong(al, lp)   /* al is a swaped return long word,*/
  148.                 /* lp is a to be swaped long word */
  149. long *al;
  150. long *lp;
  151.  
  152. {
  153.    char *p, *q;
  154.  
  155.     p = (char *)al;
  156.     q = (char *)lp;
  157.     p[0] = q[3];
  158.     p[1] = q[2];
  159.     p[2] = q[1];
  160.     p[3] = q[0];
  161. }
  162.  
  163. /*
  164.  * Get word in memory, from 8086 byte-reversed format.
  165.  *
  166.  */
  167. UWORD gw(wp, aw)
  168. UWORD *wp;
  169. UWORD *aw;
  170. {
  171.     char *p, *q;
  172.  
  173.     p = (char *)wp;
  174.     q = (char *)aw;
  175.     q[0] = p[1];
  176.     q[1] = p[0];
  177.     return *aw;
  178. }
  179.